﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Areas/Commerce/Views/Shared/Backend.Master"
    Inherits="System.Web.Mvc.ViewPage<IOrder>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
    <%:"Create new Order".Localize()%>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <h3 class="title">
        <%:"Create new Order".Localize()%>
        <%: Html.ActionLink("Back to list".Localize(), "index", null, new {id="back-to-list" })%></h3>
    <div class="step">
        <ul>
            <li class="step-add-customer current">
                <%:"Select a customer".Localize() %></li>
            <li class="separator">&gt;</li>
            <li class="step-add-product">
                <%:"Select products".Localize() %></li>
            <li class="separator">&gt;</li>
            <li class="step-order-info">
                <%:"Order info".Localize() %></li>
        </ul>
    </div>
    <%--customer--%>
    <div class="step-content" id="add-customer">
        <div class="command clearfix">
            <a href='#customer-add-dialog' class="button dialog-link" id="customer-add-link">
                <%: "Create new Customer".Localize()%></a>
            <div class="search-panel">
                <div class="search-form">
                    <form action='<%= ViewData["search_customers_action"] %>' method="get" id="search-customers-form">
                    <input type="text" name="keyword" class="customer_search_keyword" value='<%=  ViewData["search_customers_keyword"] %>' />
                    <button type="submit">
                        <%:"Search".Localize() %></button>
                    </form>
                </div>
            </div>
        </div>
        <div class="table-container">
            <table>
                <thead>
                    <tr>
                        <th class="checkbox">
                        </th>
                        <th>
                            <%: "Customer ID".Localize() %>
                        </th>
                        <th>
                            <%: "Name".Localize() %>
                        </th>
                        <th>
                            <%: "Email".Localize() %>
                        </th>
                        <th>
                            <%: "Phone number".Localize()%>
                        </th>
                        <th>
                            <%: "Country".Localize() %>
                        </th>
                        <th>
                            <%: "City".Localize() %>
                        </th>
                    </tr>
                </thead>
                <tbody id="customer-container">
                </tbody>
            </table>
        </div>
        <div class="buttons">
            <a class="button step-link" href="#add-product" id="next_to_product" message="Please select a customer">
                <%:"Next »".Localize() %></a>
        </div>
    </div>
    <%--product--%>
    <div class="step-content hide" id="add-product">
        <div class="command clearfix">
            <a class="button " id="product-select-link" href="#product-select">
                <%:"Add products".Localize() %></a>
            <a class="button product-delete" href="javascript:;">
                <%:"Delete".Localize() %></a>
        </div>
        <div class="table-container">
            <table>
                <thead>
                    <tr>
                        <th class="checkbox">
                            
                        </th>
                        <th>
                            <%:"Product name".Localize() %>
                        </th>
                        <th>
                            <%:"Variation".Localize() %>
                        </th>
                        <th>
                            <%:"Quantity".Localize() %>
                        </th>
                        <th>
                            <%:"Total".Localize() %>
                        </th>
                    </tr>
                </thead>
                <tbody id="order-item-container">
                </tbody>
            </table>
        </div>
        <div class="buttons">
            <a class="button step-link" href="#add-customer">
                <%:"« Previous".Localize() %></a> <a class="button step-link"
                href="#order-info" id="next_to_order" message="<%:"Select a product, please.".Localize() %>"" disabled="disabled">
                    <%:"Next »".Localize() %></a>
        </div>
    </div>
    <!-- Dialogs -->
    <div class="hide">
        <div class="dialog" id="customer-add-dialog" title="Create New Customer" style="height: 600px;
            width: 800px;">
            <%: Html.Partial("customer",Kooboo.IoC.ObjectContainer.CreateInstance<ICustomer>()) %>
        </div>
        <div class="dialog" id="product-select" title="Add products">
            <div class="command clearfix">
                <div class="search-panel">
                    <div class="search-form">
                        <%using (Html.BeginForm("SearchProducts", "Order", FormMethod.Get, new { id = "search-products-form" }))
                          { %>
                        <input type="text" name="keyword" />
                        <button type="submit">
                            <%:"Search".Localize() %></button>
                        <%} %>
                    </div>
                </div>
            </div>
            <div class="table-container">
                <table>
                    <thead>
                        <tr>
                            <th class="checkbox">
                                <input type="checkbox" id="select_all" title="Select all" />
                            </th>
                            <th class="action">
                                <%:"Quantity".Localize() %>
                            </th>
                            <th>
                                <%:"Product name".Localize() %> 
                            </th>
                            <th>
                                <%:"Variation".Localize() %>
                            </th>
                            <th class="numeral">
                                <%:"Price".Localize() %>
                            </th>
                        </tr>
                    </thead>
                    <tbody id="search-products-container">
                    </tbody>
                </table>
            </div>
            <div class="buttons">
                <a class="button search-products-add" href="javascript:;">
                    <%:"Add".Localize() %></a>
            </div>
        </div>
    </div>
    <%--search products--%>
    <%using (Html.BeginForm("Create", "Order", FormMethod.Post, new { id = "create-form" }))
      { %>
    <%: Html.HiddenFor(i => i.Customer.Id, new { id = "customer-id" })%>
    <div id="order-item-data-container" class="hide">
    </div>
    <div class="step-content hide" id="order-info">
        <div class="order-form clearfix">
            <div class="common-form left">
                <fieldset>
                    <legend>
                        <%:"Order info".Localize() %></legend>
                    <table>
                        <tbody>
                            <tr>
                                <th>
                                    <label>
                                        <label>
                                            <%:"Promotional code".Localize() %></label></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i=>i.Coupon,new {@class="medium"}) %>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label for="shipping">
                                        <%:"Shipping info".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.DropDownListFor(i => i.ShippingId, ViewData["Shippings"] as SelectableList,new {@class="medium"})%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"Payment info".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.DropDownListFor(i=>i.PaymentName,ViewData["Payments"] as IEnumerable<SelectListItem>,new {@class="medium"})%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"Status".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.DropDownListFor(i=>i.OrderStatus, ViewData["OrderStatus"] as IEnumerable<SelectListItem>, new { id = "status",@class="medium" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    &nbsp;
                                </th>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </fieldset>
            </div>
            <div class="common-form right">
                <fieldset>
                    <legend><span>
                        <%:"Order totals".Localize() %></span> <a href='<%= ViewData["calculate_action"] %>' class="o-icon calculate"
                        title="Calculate">
                        <%:"Calculate".Localize() %></a></legend>
                    <table>
                        <tbody>
                            <tr>
                                <th>
                                    <%:"Subtotal".Localize() %>
                                </th>
                                <td>
                                    <span id="SubTotal"></span>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <%:"Shipping & Handling".Localize() %>
                                </th>
                                <td>
                                    <span id="ShippingAndHandling"></span>
                                </td>
                            </tr>
                            <!-- 
                            <tr>
                                <th>
                                    <%:"Grand total".Localize() %>  
                                </th>
                                <td>
                                    <span id="GrandTotal"></span>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <%:"Total paid".Localize() %>
                                </th>
                                <td>
                                    <span id="TotalPaid"></span>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <%:"Total refunded".Localize() %>
                                </th>
                                <td>
                                    <span id="TotalRefunded"></span>
                                </td>
                            </tr>
                       -->
                            <tr>
                                <th>
                                    <%:"Total due".Localize() %>
                                </th>
                                <td>
                                    <span id="TotalDue"></span>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </fieldset>
            </div>
        </div>
        <div class="order-form clearfix">
            <div class="common-form left">
                <fieldset>
                    <legend>
                        <%:"Shipping address".Localize() %></legend>
                    <table id="shipping-address">
                        <tbody>
                            <tr>
                                <td colspan="2">
                                    <select class="max addressbook-selector">
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    &nbsp;
                                </th>
                                <td>
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"First name".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.FirstName, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"Last name".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.LastName, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"Address1".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.Address1, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"Address2".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.Address2, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"Country".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.DropDownList("Country", ViewData["Countries"] as SelectableList, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"State".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.State, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"City".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.City, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"Postcode".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.Postcode, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"Phone number".Localize()%></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.Phone, new { @class = "max" })%>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </fieldset>
            </div>
            <div class="common-form right">
                <fieldset>
                    <legend>
                        <%:"Billing address".Localize() %></legend>
                    <table id="billing-address">
                        <tbody>
                            <tr>
                                <td colspan="2">
                                    <select class="max addressbook-selector">
                                    </select>
                                </td>
                            </tr>
                            <tr>
                                <td colspan="2">
                                    <input id="same-address" type="checkbox" />
                                    <label class="checkbox-label" for="same-address">
                                        <%:"Same as shipping address".Localize() %></label>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"First name".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.InvoiceFirstName, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"Last name".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.InvoiceLastName, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"Address1".Localize() %> </label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.InvoiceAddress1, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"Address2".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.InvoiceAddress2, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"Country".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.DropDownList("InvoiceCountry", ViewData["InvoiceCountries"] as SelectableList, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"State".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.InvoiceState, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"City".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.InvoiceCity, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"Postcode".Localize() %></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.InvoicePostcode, new { @class = "max" })%>
                                </td>
                            </tr>
                            <tr>
                                <th>
                                    <label>
                                        <%:"Phone number".Localize()%></label>
                                </th>
                                <td>
                                    <%: Html.TextBoxFor(i => i.InvoicePhone, new { @class = "max" })%>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </fieldset>
            </div>
        </div>
        <div class="common-form order-form">
            <fieldset>
                <legend>
                    <%:"Order remark".Localize() %></legend>
                <table>
                    <tbody>
                        <tr>
                            <td>
                                <%: Html.TextAreaFor(i=>i.Remark,new {style="height: 96px; width: 100%;"}) %>
                            </td>
                        </tr>
                    </tbody>
                </table>
            </fieldset>
        </div>
        <div class="buttons">
            <a class="button step-link" href="#add-product">
                <%:"« Previous".Localize() %></a>
            <input type="submit" class="button" value="<%:"Save".Localize() %>" />
        </div>
    </div>
    <%} %>
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="MenuContent" runat="server">
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="WidgetContent" runat="server">
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="ScriptContent" runat="server">
    <%using (var loader = ClientLoader.RegisterInstance())
      {
          loader.Run(ViewData["customer_validator"] as string);
          loader.Run(ViewData["order_validator"] as string);
          loader.Require("order.create.js");
      } %>
</asp:Content>
